#pragma once

namespace AVUI {

/// <summary>Represents a property identifier and the property value for a locally set dependency property.</summary>
struct LocalValueEntry
{
public:
    DECLARE_VALUE_ELEMENT(LocalValueEntry);

#pragma region Public Methods

    /// <summary>Determines whether two <see cref="T:System.Windows.LocalValueEntry" /> instances are equal.</summary>
    /// <returns>This <see cref="M:System.Windows.LocalValueEntry.op_Equality(System.Windows.LocalValueEntry,System.Windows.LocalValueEntry)" /> implementation compares the values of the <see cref="P:System.Windows.LocalValueEntry.Property" />, and potentially compares the values of <see cref="P:System.Windows.LocalValueEntry.Value" />. The <see cref="P:System.Windows.LocalValueEntry.Property" /> component of a <see cref="T:System.Windows.LocalValueEntry" /> is a value type, so will always be a bitwise comparison. For the <see cref="P:System.Windows.LocalValueEntry.Value" /> component, this implementation employs a bitwise comparison if it is a value type. For locally set properties that have reference types, the behavior is deferred to that type's equality determination mechanisms, because it just uses the == operator on the two values internally. By default, this would be a reference equality of the values and thus the equality of the entire <see cref="T:System.Windows.LocalValueEntry" /> would become a reference equality. </returns>
    /// <param name="obj">The <see cref="T:System.Windows.LocalValueEntry" /> to compare with the current <see cref="T:System.Windows.LocalValueEntry" />.</param>
    bool Equals(Object* pObj) const
    {
        LocalValueEntry entry = UnboxValue<LocalValueEntry>(pObj);
        return (m_pDP == entry.m_pDP && m_pValue == entry.m_pValue);
    }

#pragma endregion Public Methods
 

#pragma region Public Properties

    /// <summary>Gets the identifier for the locally set dependency property that is represented by this entry. </summary>
    /// <returns>The identifier for the locally set dependency property.</returns>
    DependencyProperty* get_Property() { return m_pDP; }

    /// <summary>Gets the value of the locally set dependency property. </summary>
    /// <returns>The value of the locally set dependency property as an object. </returns>
    Object* get_Value() { return m_pValue; }

#pragma endregion Public Properties

#pragma region Public Operators

    bool operator==(const LocalValueEntry& rhs) const { return Equals(BoxValue(rhs)); }
    bool operator!=(const LocalValueEntry& rhs) const { return !(*this == rhs); }

#pragma endregion Public Operators


#pragma region Internal Methods

    LocalValueEntry(DependencyProperty* pDP, Object* pValue) : m_pDP(pDP), m_pValue(pValue) { }
    LocalValueEntry(const LocalValueEntry& other) : m_pDP(other.m_pDP), m_pValue(other.m_pValue) { }
    LocalValueEntry() : m_pDP(NULL) { }

#pragma endregion Internal Methods

#pragma region Internal Methods

private:

#pragma region Private Fields

    DependencyProperty* m_pDP;
    TRefCountedPtr<Object> m_pValue;

#pragma endregion Private Fields
};

}; // namespace AVUI



